﻿#region Usings
using System.Linq;

using BK.Model;
using BK.Repositories.Abstract;
#endregion

namespace BK.Repositories.EF
{
    public class FinancistoExpensesRepository : BaseRepository<FinancistoExpense>, IFinancistoExpensesRepository
    {
        #region C'tors
        public FinancistoExpensesRepository(BkDataContext dataContext) : base(dataContext)
        {
        }
        #endregion

        #region IFinancistoExpensesRepository Members
        public FinancistoExpense[] GetAllUnprocessed()
        {
            FinancistoExpense[] result = (from expense in ObjectSet
                                          where expense.Processed == false
                                          select expense).ToArray();
            return result;
        }

        public FinancistoExpense GetFirstUnprocessed()
        {
            FinancistoExpensesRepository repository = new FinancistoExpensesRepository(Context);

            FinancistoExpense result = (from expense in repository.ObjectSet
                                        where expense.Processed == false
                                        select expense).FirstOrDefault();

            return result;
        }
        #endregion
    }
}